package com.itheima.controller;


import com.itheima.pojo.Result;
import com.itheima.pojo.User;
import com.itheima.serice.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/user")
@RestController
public class controller {

    @Autowired
    UserService userService;

    @PostMapping("/add")
    public Result addUser(@RequestBody User user){
        userService.add(user);
        return Result.success();
    }

    @DeleteMapping("/delete/{id}")
    public Result deleteUser(@PathVariable Integer id){
        userService.delete(id);
        return Result.success();
    }
    @GetMapping("/select/{id}")
    public Result selectUserId(@PathVariable Integer id){
        userService.queryById(id);
        return Result.success();
    }
    @PutMapping("/update")
    public Result updateUser(@RequestBody User user){
        userService.updateById(user);
        return Result.success();
    }

}
